<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../../layuimini-2/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../layuimini-2/css/layuimini.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">

    <!-- 隐藏-->
    <input type="hidden" name="id">
    <div class="layui-form-item">
        <label class="layui-form-label 房间号">房间号</label>
        <div class="layui-input-block">
            <input type="text" name="roomNum" lay-verify="required" lay-reqtext="房间号不能为空" placeholder="请输入房间号" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label required">住户姓名</label>
        <div class="layui-input-block">
            <input type="text" name="name" lay-verify="required" lay-reqtext="住户姓名不能为空" placeholder="请输入住户姓名" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">性别</label>
        <div class="layui-input-block">
            <input type="text" name="sex" lay-verify="required" lay-reqtext="性别不能为空" placeholder="请输入性别" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">身份证号码</label>
        <div class="layui-input-block">
            <input type="text" name="idNum" lay-verify="required" lay-reqtext="身份证号码不能为空" placeholder="请输入身份证号码" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">手机号</label>
        <div class="layui-input-block">
            <input type="text" name="phone" lay-verify="required" lay-reqtext="手机号不能为空" placeholder="请输入手机号" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">入住时间</label>
        <div class="layui-input-block">
            <input type="text" name="enterTime" id="enterTime" lay-verify="required" lay-reqtext="入住时间不能为空" placeholder="请输入入住时间" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">入住天数</label>
        <div class="layui-input-block">
            <input type="text" name="days" lay-verify="required" lay-reqtext="入住天数不能为空" placeholder="请输入入住天数" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">更新</button>
        </div>
    </div>
</div>
</div>
<script src="../../../layuimini-2/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            laydate= layui.laydate,
            $ = layui.$;

        setTimeout(function () {
            form.render();//重新渲染表格
        },50);//定时

        laydate.render({
            elem:'#enterTime' //指定元素
        });



        //监听提交
        form.on('submit(saveBtn)', function (obj) {
            $.ajax({
                url:"/consumer/update.do",
                type:"get",
                data:obj.field,
                success:function (ret) {
                    if (ret.code==0) {
                        let index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    } else {
                        layer.msg("编辑信息失败");
                    }
                },
                error:function (ret) {
                    layer.msg("服务器忙!!")
                }
            })
            return false;//防止自动提交表单
        })

    });
</script>
</body>
</html>